﻿
<template>
    <section>




        <!--工具条-->
        <el-col :span='24' class='toolbar' style='padding-bottom: 0px;'>
            <el-form :inline='true' :model='filters' @submit.native.prevent>
                <el-form-item>
                    <el-input v-model='filters.name' placeholder='名称/Key'></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type='primary' @click='getDtoPage'>查询</el-button>
                </el-form-item>
                <el-form-item>
                    <el-button type='primary' @click='handleAdd'>新增</el-button>
                </el-form-item>
                <el-button type='danger' @click='batchRemove' :disabled='this.sels.length===0'>批量删除</el-button>
            </el-form>
        </el-col>



        <!--列表-->
        <el-table :data='users'
                  highlight-current-row
                  v-loading='listLoading'
                  @selection-change='selsChange'
                  style='width: 100%;'
                  sortable='custom' @sort-change='sortKey'>

            <!--<el-table-column prop='EquipmentId' label='编号' width='' sortable>  </el-table-column>-->
            <el-table-column prop='ProjectId' label='所属项目' width='' sortable>  </el-table-column>
            <!--<el-table-column prop='QRCode' label='二维码' width='' sortable>  </el-table-column>-->
            <el-table-column prop='CategoryId' label='设备类型' width='' sortable>  </el-table-column>
            <el-table-column prop='EquipmenName' label='设备名称' width='' sortable>  </el-table-column>
            <el-table-column prop='EquipmenCode' label='设备编号' width='' sortable>  </el-table-column>
            <el-table-column prop='Model' label='设备型号' width='' sortable>  </el-table-column>
            <el-table-column prop='MachineRoom' label='机房' width=''>  </el-table-column>
            <el-table-column prop='EQAddress' label='安装位置' width=''>  </el-table-column>
            <el-table-column prop='Factory' label='厂家' width='' sortable>  </el-table-column>
            <el-table-column prop='FactoryDate' label='出厂日期' width='' sortable>  </el-table-column>
            <el-table-column prop='FactoryTel' label='厂家电话' width=''>  </el-table-column>
            <el-table-column prop='ManageUserID' label='负责人ID' width=''>  </el-table-column>
            <!--<el-table-column prop='FromId' label='表单ID' width='' sortable>  </el-table-column>-->
            <!--<el-table-column prop='AboutUsage' label='用途' width='' sortable>  </el-table-column>-->
            <!--<el-table-column prop='MaintenanceContents' label='保养内容' width='' sortable>  </el-table-column>
            <el-table-column prop='Remarks' label='备注' width='' sortable>  </el-table-column>
            <el-table-column prop='DeleteMark' label='软删除 0未删除，1 已删除' width='' sortable>  </el-table-column>
            <el-table-column prop='SortCode' label='排序 排序' width='' sortable>  </el-table-column>
            <el-table-column prop='Enabled' label='是否启用 0未启用，1启用' width='' sortable>  </el-table-column>
            <el-table-column prop='CreateDate' label='填报时间 创建时间' width='' sortable>  </el-table-column>
            <el-table-column prop='CreateUserID' label='填报用户ID 创建的用户ID' width='' sortable>  </el-table-column>
            <el-table-column prop='CreateUserName' label='创建的用户名称 创建的用户名称' width='' sortable>  </el-table-column>
            <el-table-column prop='ModifyDate' label='最后一次修改时间 修改日期' width='' sortable>  </el-table-column>
            <el-table-column prop='ModifyUserId' label='修改用户编号 修改用户编号' width='' sortable>  </el-table-column>
            <el-table-column prop='ModifyUserName' label='修改的用户姓名 修改的用户姓名' width='' sortable>  </el-table-column>-->


            <el-table-column label='操作' width='150'>
                <template scope='scope'>
                    <el-button size='small' @click='handleEdit(scope.$index, scope.row)'> 编辑 </el-button>
                    <el-button type='danger' size='small' @click='handleDel(scope.$index, scope.row)'> 删除 </el-button>
                </template>
            </el-table-column>

        </el-table>



        <!-- 工具条 ,分页 -->
        <el-col :span='24' class='toolbar'>
            <el-pagination @size-change="handleSizeChange"
                           @current-change="handleCurrentChange"
                           :current-page="pageIndex"
                           :page-sizes="[ 20, 50, 100]"
                           :page-size="pageSize"
                           layout="total, sizes, prev, pager, next, jumper"
                           :total="total"
                           style='float:right;'>
            </el-pagination>
        </el-col>



        <!--编辑界面-->
        <el-dialog title='编辑' :visible.sync='editFormVisible' v-model='editFormVisible' :close-on-click-modal='false'>
            <el-form :model='editForm' label-width='80px' :rules='editFormRules' ref='editForm'>

                <el-form-item label='编号' prop='EquipmentId'>
                    <el-input v-model='editForm.EquipmentId' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='项目ID' prop='ProjectId'>
                    <el-input v-model='editForm.ProjectId' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='二维码' prop='QRCode'>
                    <el-input v-model='editForm.QRCode' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='设备类型ID' prop='CategoryId'>
                    <el-input v-model='editForm.CategoryId' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='设备名称' prop='EquipmenName'>
                    <el-input v-model='editForm.EquipmenName' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='设备编号' prop='EquipmenCode'>
                    <el-input v-model='editForm.EquipmenCode' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='设备型号' prop='Model'>
                    <el-input v-model='editForm.Model' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='机房' prop='MachineRoom'>
                    <el-input v-model='editForm.MachineRoom' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='安装位置' prop='EQAddress'>
                    <el-input v-model='editForm.EQAddress' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='厂家' prop='Factory'>
                    <el-input v-model='editForm.Factory' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='出厂日期' prop='FactoryDate'>
                    <el-input v-model='editForm.FactoryDate' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='厂家电话' prop='FactoryTel'>
                    <el-input v-model='editForm.FactoryTel' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='负责人ID' prop='ManageUserID'>
                    <el-input v-model='editForm.ManageUserID' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='表单ID' prop='FromId'>
                    <el-input v-model='editForm.FromId' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='用途' prop='AboutUsage'>
                    <el-input v-model='editForm.AboutUsage' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='保养内容' prop='MaintenanceContents'>
                    <el-input v-model='editForm.MaintenanceContents' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='备注' prop='Remarks'>
                    <el-input v-model='editForm.Remarks' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='软删除 0未删除，1 已删除' prop='DeleteMark'>
                    <el-input v-model='editForm.DeleteMark' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='排序 排序' prop='SortCode'>
                    <el-input v-model='editForm.SortCode' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='是否启用 0未启用，1启用' prop='Enabled'>
                    <el-input v-model='editForm.Enabled' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='填报时间 创建时间' prop='CreateDate'>
                    <el-input v-model='editForm.CreateDate' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='填报用户ID 创建的用户ID' prop='CreateUserID'>
                    <el-input v-model='editForm.CreateUserID' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='创建的用户名称 创建的用户名称' prop='CreateUserName'>
                    <el-input v-model='editForm.CreateUserName' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='最后一次修改时间 修改日期' prop='ModifyDate'>
                    <el-input v-model='editForm.ModifyDate' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='修改用户编号 修改用户编号' prop='ModifyUserId'>
                    <el-input v-model='editForm.ModifyUserId' auto-complete='off'></el-input>
                </el-form-item>


                <el-form-item label='修改的用户姓名 修改的用户姓名' prop='ModifyUserName'>
                    <el-input v-model='editForm.ModifyUserName' auto-complete='off'></el-input>
                </el-form-item>


            </el-form>
            <div slot='footer' class='dialog-footer'>
                <el-button @click.native='editFormVisible = false'>取消</el-button>
                <el-button type='primary' @click.native='editSubmit' :loading='editLoading'>提交</el-button>
            </div>
        </el-dialog>



        <!--新增界面-->
        <el-dialog title='新增' :visible.sync='addFormVisible' v-model='addFormVisible' :close-on-click-modal='false'>

            <el-form :model='addForm' label-width='80px' :rules='addFormRules' ref='addForm'>

                <template>
                    <el-tabs v-model="activeName" type="card">
                        <el-tab-pane label="基本属性" name="first">
                            <el-form-item label='所属项目' prop='ProjectId'>
                                <el-input v-model='addForm.ProjectId' auto-complete='off'></el-input>
                            </el-form-item>
                            <el-form-item label='设备类型' prop='CategoryId'>
                                <el-input v-model='addForm.CategoryId' auto-complete='off'></el-input>
                            </el-form-item>


                            <el-form-item label='设备名称' prop='EquipmenName'>
                                <el-input v-model='addForm.EquipmenName' auto-complete='off'></el-input>
                            </el-form-item>


                            <el-form-item label='设备编号' prop='EquipmenCode'>
                                <el-input v-model='addForm.EquipmenCode' auto-complete='off'></el-input>
                            </el-form-item>


                            <el-form-item label='设备型号' prop='Model'>
                                <el-input v-model='addForm.Model' auto-complete='off'></el-input>
                            </el-form-item>


                            <!--<el-form-item label='机房' prop='MachineRoom'>
                                <el-input v-model='addForm.MachineRoom' auto-complete='off'></el-input>
                            </el-form-item>-->


                            <el-form-item label='安装位置' prop='EQAddress'>
                                <el-input v-model='addForm.EQAddress' auto-complete='off'></el-input>
                            </el-form-item>


                            <el-form-item label='厂家' prop='Factory'>
                                <el-input v-model='addForm.Factory' auto-complete='off'></el-input>
                            </el-form-item>


                            <el-form-item label='出厂日期' prop='FactoryDate'>
                                <el-input v-model='addForm.FactoryDate' auto-complete='off'></el-input>
                            </el-form-item>


                            <el-form-item label='厂家电话' prop='FactoryTel'>
                                <el-input v-model='addForm.FactoryTel' auto-complete='off'></el-input>
                            </el-form-item>


                            <el-form-item label='负责人' prop='ManageUserID'>
                                <el-input v-model='addForm.ManageUserID' auto-complete='off'></el-input>
                            </el-form-item>


                            <!--<el-form-item label='表单ID' prop='FromId'>
                                <el-input v-model='addForm.FromId' auto-complete='off'></el-input>
                            </el-form-item>-->


                            <el-form-item label='用途' prop='AboutUsage'>
                              
                                <el-input type="textarea" v-model="addForm.AboutUsage"></el-input>
                            </el-form-item>


                            <el-form-item label='保养内容' prop='MaintenanceContents'>
                                <!--<el-input v-model='addForm.MaintenanceContents' auto-complete='off'></el-input>-->
                                <el-input type="textarea" v-model="addForm.MaintenanceContents"></el-input>
                            </el-form-item>


                            <el-form-item label='备注' prop='Remarks'>
                      
                                <el-input type="textarea" v-model="addForm.Remarks"></el-input>
                            </el-form-item>


                            <!--<el-form-item label='软删除 0未删除，1 已删除' prop='DeleteMark'>
                                <el-input v-model='addForm.DeleteMark' auto-complete='off'></el-input>
                            </el-form-item>-->


                            <el-form-item label='排序' prop='SortCode'>
                                <el-input v-model='addForm.SortCode' auto-complete='off'></el-input>
                            </el-form-item>


                            <el-form-item label='是否启用' prop='Enabled'>
                                <!--<el-input v-model='addForm.Enabled' auto-complete='off'></el-input>-->
                                <el-switch v-model="addForm.Enabled"
                                           active-color="#13ce66"
                                           inactive-color="#ff4949">
                                </el-switch>
                            </el-form-item>
                        </el-tab-pane>
                        <el-tab-pane label="自定义属性" name="second">自定义属性</el-tab-pane>

                    </el-tabs>
                </template>

                <!--<el-form-item label='编号' prop='EquipmentId'>
                    <el-input v-model='addForm.EquipmentId' auto-complete='off'></el-input>
                </el-form-item>-->
                <!--<el-form-item label='二维码' prop='QRCode'>
                    <el-input v-model='addForm.QRCode' auto-complete='off'></el-input>
                </el-form-item>-->





            </el-form>
            <div slot='footer' class='dialog-footer'>
                <el-button @click.native='addFormVisible = false'>取消</el-button>
                <el-button type='primary' @click.native='addSubmit' :loading='addLoading'>提交</el-button>
            </div>
        </el-dialog>





    </section>
</template>

<script>

    import util from '../../../util/date'
    import { testapi, getPage_Base_Equipment, getByID_Base_Equipment, edit_Base_Equipment, add_Base_Equipment, batchRemove_Base_Equipment, Remove_Base_Equipment } from '../../api/api';

    export default {
        data() {   // 全局变量
            return {
                activeName: 'first',
                filters: { name: '' },
                users: [],
                //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                total: 0,
                pageSize: 20,
                pageIndex: 1,
                sidx: null,   //  排序字段
                order: null,  //  排序方式， 正序\倒序
                //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                listLoading: false,
                sels: [],//列表选中列
                addDialogFormVisible: false,
                editFormVisible: false,//编辑界面是否显示
                editLoading: false,
                editFormRules: {
                    EquipmentId: [{ required: true, message: '请输入编号', trigger: 'blur' }],
                    ProjectId: [{ required: true, message: '请输入项目ID', trigger: 'blur' }],
                    QRCode: [{ required: true, message: '请输入二维码', trigger: 'blur' }],
                    CategoryId: [{ required: true, message: '请输入设备类型ID', trigger: 'blur' }],
                    EquipmenName: [{ required: true, message: '请输入设备名称', trigger: 'blur' }],
                    EquipmenCode: [{ required: true, message: '请输入设备编号', trigger: 'blur' }],
                    Model: [{ required: true, message: '请输入设备型号', trigger: 'blur' }],
                    MachineRoom: [{ required: true, message: '请输入机房', trigger: 'blur' }],
                    EQAddress: [{ required: true, message: '请输入安装位置', trigger: 'blur' }],
                    Factory: [{ required: true, message: '请输入厂家', trigger: 'blur' }],
                    FactoryDate: [{ required: true, message: '请输入出厂日期', trigger: 'blur' }],
                    FactoryTel: [{ required: true, message: '请输入厂家电话', trigger: 'blur' }],
                    ManageUserID: [{ required: true, message: '请输入负责人ID', trigger: 'blur' }],
                    FromId: [{ required: true, message: '请输入表单ID', trigger: 'blur' }],
                    AboutUsage: [{ required: true, message: '请输入用途', trigger: 'blur' }],
                    MaintenanceContents: [{ required: true, message: '请输入保养内容', trigger: 'blur' }],
                    Remarks: [{ required: true, message: '请输入备注', trigger: 'blur' }],
                    DeleteMark: [{ required: true, message: '请输入软删除 0未删除，1 已删除', trigger: 'blur' }],
                    SortCode: [{ required: true, message: '请输入排序 排序', trigger: 'blur' }],
                    Enabled: [{ required: true, message: '请输入是否启用 0未启用，1启用', trigger: 'blur' }],
                    CreateDate: [{ required: true, message: '请输入填报时间 创建时间', trigger: 'blur' }],
                    CreateUserID: [{ required: true, message: '请输入填报用户ID 创建的用户ID', trigger: 'blur' }],
                    CreateUserName: [{ required: true, message: '请输入创建的用户名称 创建的用户名称', trigger: 'blur' }],
                    ModifyDate: [{ required: true, message: '请输入最后一次修改时间 修改日期', trigger: 'blur' }],
                    ModifyUserId: [{ required: true, message: '请输入修改用户编号 修改用户编号', trigger: 'blur' }],
                    ModifyUserName: [{ required: true, message: '请输入修改的用户姓名 修改的用户姓名', trigger: 'blur' }],
                }
                ,
                //编辑界面数据
                editForm: {
                    EquipmentId: '',
                    ProjectId: '',
                    QRCode: '',
                    CategoryId: '',
                    EquipmenName: '',
                    EquipmenCode: '',
                    Model: '',
                    MachineRoom: '',
                    EQAddress: '',
                    Factory: '',
                    FactoryDate: '',
                    FactoryTel: '',
                    ManageUserID: '',
                    FromId: '',
                    AboutUsage: '',
                    MaintenanceContents: '',
                    Remarks: '',
                    DeleteMark: 0,
                    SortCode: 0,
                    Enabled: 0,
                    CreateDate: 0,
                    CreateUserID: '',
                    CreateUserName: '',
                    ModifyDate: 0,
                    ModifyUserId: '',
                    ModifyUserName: '',
                }
                ,
                addFormVisible: false,//新增界面是否显示
                addLoading: false,
                addFormRules: {
                    EquipmentId: [{ required: true, message: '请输入编号', trigger: 'blur' }],
                    ProjectId: [{ required: true, message: '请选择所属项目', trigger: 'blur' }],
                    //QRCode: [{ required: true, message: '请输入二维码', trigger: 'blur' }],
                    CategoryId: [{ required: true, message: '请选择所属设备类型', trigger: 'blur' }],
                    EquipmenName: [{ required: true, message: '请输入设备名称', trigger: 'blur' }],
                    EquipmenCode: [{ required: true, message: '请输入设备编号', trigger: 'blur' }],
                    Model: [{ required: true, message: '请输入设备型号', trigger: 'blur' }],
                    MachineRoom: [{ required: true, message: '请输入机房', trigger: 'blur' }],
                    EQAddress: [{ required: true, message: '请输入安装位置', trigger: 'blur' }],
                    Factory: [{ required: true, message: '请输入厂家', trigger: 'blur' }],
                    FactoryDate: [{ required: true, message: '请输入出厂日期', trigger: 'blur' }],
                    FactoryTel: [{ required: true, message: '请输入厂家电话', trigger: 'blur' }],
                    ManageUserID: [{ required: true, message: '请输入负责人ID', trigger: 'blur' }],
                    AboutUsage: [{ required: true, message: '请输入用途', trigger: 'blur' }],
                    MaintenanceContents: [{ required: true, message: '请输入保养内容', trigger: 'blur' }],
                    Remarks: [{ required: true, message: '请输入备注', trigger: 'blur' }],

                    SortCode: [{ required: true, message: '请输入排序 排序', trigger: 'blur' }],
                    Enabled: [{ required: true, message: '请输入是否启用 0未启用，1启用', trigger: 'blur' }],

                }
                ,
                //新增界面数据
                addForm: {
                    ProjectId: '',
                    QRCode: '',
                    CategoryId: '',
                    EquipmenName: '',
                    EquipmenCode: '',
                    Model: '',
                    MachineRoom: '',
                    EQAddress: '',
                    Factory: '',
                    FactoryDate: '',
                    FactoryTel: '',
                    ManageUserID: '',
                    FromId: '',
                    AboutUsage: '',
                    MaintenanceContents: '',
                    Remarks: '',
                    DeleteMark: 0,
                    SortCode: 0,
                    Enabled: 1,

                }

            }
        },
        methods: {    // 全局方法
            //性别显示转换
            //formatSex: function (row, column) {
            //    return row.C_Value == 2 ? '男' : row.C_Value;
            //},
            //formatterCreateTime: function (row, column) {
            //    return (!row.C_CreateTime || row.C_CreateTime == '') ? '' : util.formatDate.format(new Date(row.C_CreateTime), 'yyyy-MM-dd');
            //},
            handleCurrentChange(val) {
                this.page = val;
                this.getDtoPage();
            },
            // 测试
            sortKey(val) {
                console.log(val)
            },
            // 每页数
            handleSizeChange(val) {
                this.pageSize = val;
                this.pageIndex = 1;
                this.getDtoPage();
            },

            //获取用户列表
            getDtoPage() {
                let para = {
                    page: this.pageIndex,
                    pageSize: this.pageSize,
                    key: this.filters.name,
                    sidx: this.sidx,
                    order: this.order
                };
                this.listLoading = true;

                getPage_Base_Equipment(para).then((res) => {
                    console.log(res);
                    this.total = res.data.response.dataCount;
                    this.users = res.data.response.data;
                    this.listLoading = false;

                });
            },
            //删除
            handleDel: function (index, row) {
                this.$confirm('确认删除该记录吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.listLoading = true;
                    let para = { id: row.EquipmentId };
                    Remove_Base_Equipment(para).then((res) => {
                        if (util.isEmt.format(res)) {
                            this.listLoading = false;
                            return;
                        }
                        this.listLoading = false;
                        if (res.data.success) {
                            this.$message({
                                message: '删除成功',
                                type: 'success'
                            });
                        } else {
                            this.$message({
                                message: res.data.msg,
                                type: 'error'
                            });
                        }
                        this.getDtoPage();
                    });
                }).catch((c) => {
                    console.log(c);
                });
            },
            //显示编辑界面
            handleEdit: function (index, row) {
                this.editFormVisible = true;

                let para_getGetByID = { id: row.EquipmentId };

                getByID_Base_Equipment(para_getGetByID).then((getDto) => {

                    this.editForm = Object.assign({}, getDto.data.response);
                });
            },
            //显示新增界面
            handleAdd() {
                this.addFormVisible = true;
                this.addForm = {
                    ProjectId: '',
                    QRCode: '',
                    CategoryId: '',
                    EquipmenName: '',
                    EquipmenCode: '',
                    Model: '',
                    MachineRoom: '',
                    EQAddress: '',
                    Factory: '',
                    FactoryDate: '',
                    FactoryTel: '',
                    ManageUserID: '',
                    FromId: '',
                    AboutUsage: '',
                    MaintenanceContents: '',
                    Remarks: '',
                    DeleteMark: 0,
                    SortCode: 0,
                    Enabled: 0,
                    CreateDate: 0,
                    CreateUserID: '',
                    CreateUserName: '',
                    ModifyDate: 0,
                    ModifyUserId: '',
                    ModifyUserName: '',
                }
                    ;
            },
            //编辑
            editSubmit: function () {
                this.$refs.editForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                        }).then(() => {
                            this.editLoading = true;
                            //NProgress.start();
                            let para = Object.assign({}, this.editForm);
                            console.log(para);
                            edit_Base_Equipment(para).then((res) => {

                                if (util.isEmt.format(res)) {
                                    this.editLoading = false;
                                    return;
                                }
                                if (res.data.success) {
                                    this.editLoading = false;

                                    this.$message({
                                        message: res.data.msg,
                                        type: 'success'
                                    });
                                    this.$refs['editForm'].resetFields();
                                    this.editFormVisible = false;
                                    this.getDtoPage();
                                } else {
                                    this.$message({
                                        message: res.data.msg,
                                        type: 'error'
                                    });
                                }
                            });
                        });
                    }
                });
            },
            //新增
            addSubmit: function () {
                this.$refs.addForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                        }).then(() => {
                            this.addLoading = true;
                            let para = Object.assign({}, this.addForm);

                            add_Base_Equipment(para).then((res) => {

                                if (util.isEmt.format(res)) {
                                    this.addLoading = false;
                                    return;
                                }

                                if (res.data.success) {
                                    this.addLoading = false;
                                    this.$message({
                                        message: res.data.msg,
                                        type: 'success'
                                    });
                                    this.$refs['addForm'].resetFields();
                                    this.addFormVisible = false;
                                    this.getDtoPage();
                                }
                                else {
                                    this.$message({
                                        message: res.data.msg,
                                        type: 'error'
                                    });
                                }
                            });
                        });
                    }
                });
            },
            selsChange: function (sels) {
                this.sels = sels;
            },
            //批量删除
            batchRemove: function () {

                var ids = this.sels.map(item => item.EquipmentId).toString();
                this.$confirm('确认删除选中记录吗？', '提示', {
                    type: 'warning',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消'
                }).then(() => {
                    this.listLoading = true;
                    let para = { ids: ids };

                    batchRemove_Base_Equipment(para).then((res) => {
                        this.listLoading = false;

                        if (res.data.success) {
                            this.$message({
                                message: '删除成功',
                                type: 'success'
                            });
                        } else {
                            this.$message({
                                message: res.data.msg,
                                type: 'error'
                            });
                        }
                        this.getDtoPage();
                        console.log(res)
                    });
                }).catch(() => {

                });
            }
        },
        mounted() {
            this.getDtoPage();
        }
    }

</script>

<style scoped>
</style>
